<script>
	$(function(){
		$('#Poster_Filename').on('change',function(){
			//console.log($('#Poster_Filename'));
		//	console.log(getPath(document.getElementById('Poster_Filename')));
			$('#preview').html("<img src='"+$('#Poster_Filename').val()+"'/>");
			
		})
//		console.log($('#Poster_Filename'));
		
	})
	
	function getPath(obj)  //参数obj为input file对象
{  
  if(obj)  
    {  
 
    if (window.navigator.userAgent.indexOf("MSIE")>=1)  
      {  
        obj.select();  
 
      return document.selection.createRange().text;  
      }  
 
    else if(window.navigator.userAgent.indexOf("Firefox")>=1)  
      {  
      if(obj.files)  
        {  
 
        return obj.files.item(0).getAsDataURL();  
        }  
      return obj.value;  
      }  
    return obj.value;  
    }  
}
	
</script>
<div class="form">

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'poster-form',
	'enableAjaxValidation'=>false,
	'htmlOptions'=>array('enctype'=>'multipart/form-data'), 
)); ?>

	<p class="note">Fields with <span class="required">*</span> are required.</p>

	<?php echo $form->errorSummary($model); ?>

	<div class="row">
		<?php echo $form->labelEx($model,'Title'); ?>
		<?php echo $form->textField($model,'Title',array('size'=>60,'maxlength'=>64)); ?>
		<?php echo $form->error($model,'Title'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'Url'); ?>
		<?php echo $form->textField($model,'Url',array('size'=>60,'maxlength'=>256)); ?>
		<?php echo $form->error($model,'Url'); ?>
	</div>


	<div class="row">
		<?php echo $form->labelEx($model,'Position'); ?>
		<?php echo $form->dropdownlist($model,'Position',array('11'=>'页面左侧','12'=>'页面右侧','13'=>'页面中间',),array('empty'=>'请选择广告位置')); ?>
		<?php echo $form->error($model,'Position'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'Filename'); ?>
		<?php echo $form->fileField($model,'Filename',array(
		)); ?><div id='preview'></div>
		<?php echo $form->error($model,'Filename'); ?>
	</div>

	<div class="row buttons">
		<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
	</div>

<?php $this->endWidget(); ?>

</div><!-- form -->